package com.ma4567.remotecontroller.util;

public class File {
    public String FilePath;
    public String FileName;
    public String FileType;

    public File(String filePath, String fileName, String fileType) {
        this.FilePath = filePath;
        this.FileName = fileName;

        java.io.File file = new java.io.File(filePath);
        if(file.exists() && file.isDirectory() && !"Disk".equals(fileType)) {
            FileType = "Folder";
        } else if("Disk".equals(fileType)) {
            FileType = "Disk";
        } else {
            switch (FileName.split("\\.")[FileName.split("\\.").length - 1]) {
                case "pdf" -> FileType = "Pdf";
                case "txt", "csv", "ini", "json", "log" -> FileType = "Txt";
                case "docx", "doc" -> FileType = "Word";
                case "pptx", "ppt" -> FileType = "PPT";
                case "xlsx", "xls" -> FileType = "Xls";
                case "png", "jpg", "jpeg", "bmp", "gif", "tif", "raw", "tga" -> FileType = "Photo";
                case "zip", "7z", "rar", "tar", "xz", "unitypackage" -> FileType = "Zip";
                case "mp4", "mp3", "avi", "flv", "rmvb", "wmv", "mov" -> FileType = "Video";
                default -> FileType = "File";
            }
        }
        this.FilePath = this.FilePath.replace("\\", "%5C");
    }
}
